package com.chapter02;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.SQLException;
import java.util.Properties;

public class TestConnection1 {
    public static void main(String[] args) throws SQLException {
        // todo 创建一个驱动
        Driver driver = new com.mysql.jdbc.Driver();

        // todo 准备连接数据库的要素
        String url = "jdbc:mysql://127.0.0.1:3306/myschool";
        String userName = "root";
        String userPwd = "root";
        Properties properties = new Properties();
        properties.put("user",userName);
        properties.put("password",userPwd);

        // todo 通过驱动获取一个连接对象
        Connection connect = driver.connect(url, properties);

        // todo 输出连接对象
        System.out.println(connect.getClass().getName());
    }
}
